home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmlsrc23.zoo / doc / header.r next >
Encoding:
Text File  |  1994-03-19  |  7.6 KB  |  243 lines

  1. .tp
  2. .(1C
  3. P M L    U S E R S   G U I D E
  4. .sp 2
  5. P o r t a b l e   M a t h   L i b r a r y
  6. .sp 2
  7. Version 2.0
  8. .sp 2
  9. \*(td
  10. .sp 4
  11. by
  12. .sp
  13. Fred Fish
  14. .)1
  15. .bp
  16. .sh 1
  17. INTRODUCTION
  18. .(x
  19. document topics
  20. .)x
  21. .sh 2
  22. Document structure
  23. .pp
  24. This document describes the PML library, a
  25. mathematical function library for C programs.
  26. It contains the following major sections:
  27. .(1
  28. Introduction to the document (this section).
  29. A module description section.
  30. An index.
  31. .)1
  32. .sh 2 
  33. Design Considerations
  34.  
  35. .pp
  36. In writing this library many tradeoffs had to be considered.  The
  37. primary design goal was transportability.  It was desired that
  38. the final library be easily transportable among a wide class
  39. of machines.  As of this release, the library has been used
  40. with only minor modifications on
  41. a DECSYSTEM-20 (a 36 bit machine), a VAX-11/780 under compatibility
  42. mode, and various PDP-11's.
  43.  
  44. .pp
  45. This portability was achieved by careful isolation of machine
  46. dependencies and parameterization of the environment (see references).
  47. The only assumption made is that the C compiler can generate proper code for
  48. the four basic operations (+,-,/,*).
  49.  
  50. .pp
  51. Even though efficiency
  52. was considered to be of only secondary importance, the final routines
  53. compared favorably with an informal test "race" against the
  54. DECSYSTEM-20 FORTRAN, which has optimized assembly language
  55. library routines.  The PML library routines seldom took
  56. more than twice as long as the FORTRAN library, and many were
  57. close enough to call a draw.
  58.  
  59. .pp
  60. There are currently only four highly machine dependent routines in
  61. the Portable Math Library.  When transporting the library to a new machine,
  62. these should be the only ones in which recoding is necessary.
  63. These routines, written in machine targeted C, are:
  64.  
  65. .pp
  66. dscale --- scale a double precision floating point number by a specified
  67. power of two.  Equivalent to multiplication or division
  68. by a power of two, depending upon sign of the scale value.
  69.  
  70. .pp
  71. dxexp --- extract exponent of double precision floating point number and
  72. return it as an integer.
  73.  
  74. .pp
  75. dxmant --- extract mantissa of double precision floating point number and
  76. return it as a double precision floating point number.
  77.  
  78. .pp
  79. dint --- discard fractional part of double precision number, returning
  80. integer part as a double precision floating point
  81. number.
  82.  
  83. .pp
  84. The entire Portable Math Library is built upon six "primitives"
  85. which compute their values from polynomial approximations.  All
  86. others can be defined in terms of the primitives using various
  87. identities.  The primitives are (1) datan, (2) dexp, (3) dln, 
  88. (4) dsin, (5) dcos, and (6) dsqrt.  Strictly speaking, only
  89. one of dsin and dcos could be chosen as a primitive and the
  90. other defined with an appropriate identity.  In this implementation
  91. however, dsin and dcos call themselves recursively, and each other,
  92. to perform range reduction.
  93.  
  94. .sh 2
  95. Error Handling
  96.  
  97. .pp
  98. No assumptions are made about whether the four basic operations are done by
  99. hardware or software.  Any overflows or underflows in the basic operations
  100. are assumed to be handled by the environment, if at all.  Pathological
  101. cases in the library routines are trapped internally and control
  102. is passed to an error handler routine "pmlerr"
  103. (which may be replaced with
  104. one of the user's choosing) for error recovery.
  105.  
  106. .pp
  107. The default error handler is conceptually similar to the one used by DEC for
  108. the FORTRAN compilers.  It contains an internal table which
  109. allows various actions to be taken for each error recognized.
  110. Currently each error has a corresponding flag word with three
  111. bits, each bit assigned as follows:
  112.  
  113. .pp
  114. CONTINUE --- If the bit is set control is returned to the calling
  115. routine after completion of error processing.  Otherwise
  116. the task exits with an error status.
  117.  
  118. .pp
  119. LOG --- If the log bit is set then an error warning message is
  120. written to the standard error output channel prior to exiting
  121. or continuing.  If reset, no message is given.
  122.  
  123. .pp
  124. COUNT --- If the count bit is set then the task's PML
  125. error count (internal to the error handler) is incremented.
  126. If the total error count exceeds the maximum allowed 
  127. then the task exits with
  128. error status.  If the count bit is reset then the error
  129. is ignored with respect to the error count and exit on limit.
  130.  
  131. .pp
  132. The default conditions in the error handler for all errors
  133. is that the CONTINUE, LOG, and COUNT bits are all set.  The
  134. error limit is set at 10.  These values can be changed by
  135. suitably editing the header file "pml.h"
  136. and <pmluser.h>.
  137.  
  138. .pp
  139. The error handler responses can also be changed dynamically
  140. via the following routines:
  141.  
  142. .pp
  143. PMLSFS --- Sets the specified bits in the specified error's
  144. flag word.
  145. For example, "pmlsfs(NEG__DSQRT,CONTINUE | LOG)" sets
  146. the CONTINUE and LOG bits for the "double precision square root
  147. of a negative number" error.  The COUNT bit is not affected.
  148. The manifest constant values are defined in <pmluser.h>.
  149.  
  150. .pp
  151. PMLCFS --- Clears the specified bits in the specified error's
  152. flag word.
  153. For example, "pmlcfs(NEG__DSQRT,CONTINUE | LOG)" clears
  154. the CONTINUE and LOG bits for the "double precision square root
  155. of a negative number" error.  The COUNT bit is not affected.
  156. The manifest constant values are defined in <pmluser.h>.
  157.  
  158. .pp
  159. PMLLIM --- Changes the task's PML error limit to
  160. the specified value and returns the previous value.
  161.  
  162. .pp
  163. PMLCNT --- Returns the current value of the PML error
  164. count and resets it back to zero.
  165.  
  166. .sh 2
  167. Function Names
  168.  
  169. .pp
  170. In general, FORTRAN naming conventions were followed since no
  171. other more obvious convention was apparent.  There is one
  172. strong exception however, and that is the natural
  173. logarithm functions use the generic name "ln" while the
  174. logarithm to the base 10 functions use the name "log".
  175. This is consistent with the normal usage in virtually all
  176. modern mathematical and engineering texts.  How FORTRAN came
  177. to use "log" and "log10" respectively is beyond me.
  178. This usage has bitten many a starting FORTRAN programmer.
  179.  
  180. .sh 2
  181. Installation
  182.  
  183. .pp
  184. As part of the installation kit, some simple minded testing programs
  185. are provided.  They are by no means exhaustive tests or ones that
  186. carefully check possible trouble areas.  They are intended to
  187. provide a quick and dirty way of verifying that no gross errors
  188. are inadvertently incorporated in the library as a result of
  189. improvements or bug fixes, and that the installation is successful.
  190. Future releases may incorporate more extensive test routines
  191. and suggestions are solicited.
  192.  
  193. .sh 2
  194. Bugs
  195.  
  196. .pp
  197. On the subject of bugs, all exterminators are encouraged
  198. to notify the author of any problems or fixes so that
  199. they can be incorporated into the next release and renegade
  200. versions of the library can be minimized.  
  201. Contact:
  202. .sp 2
  203. .nf
  204.         Fred Fish
  205.         1346 W 10th Place
  206.         Tempe, Arizona 85281
  207. .sp 1
  208.         (602) 894-6881   (home)
  209.         (602) 932-7000   (work @ GACA)
  210. .fi
  211. .sp 2
  212. .pp
  213. Those users with strong numerical analysis backgrounds or experience
  214. may be able to suggest better methods for some of the library routines.
  215. Many of the higher level routines are simple minded implementations
  216. of identities, and may not be nearly as stable as some more obscure
  217. methods.
  218.  
  219. .sh 2
  220. Transporting To Other Machines
  221.  
  222. .pp
  223. To transport the Portable Math Library to a processor other than
  224. the PDP11 or DECSYSTEM-20, do the following:
  225. .(1
  226. Define the machine dependent parameters in "pml.h".
  227. Implement the four machine dependent modules listed previously.
  228. Compile the rest of the library modules and the testing routines.
  229. Link and run the testing routines to verify successful installation.
  230. Repeat as required.
  231. .)1
  232.  
  233. .bp
  234. .sh 1 
  235. RUNTIME MODULES
  236.  
  237. .pp
  238. The PML modules are documented on the following pages.
  239. All the rest of this section was produced by the DEX (documentation
  240. extractor) utility directly from the source files.  Thus
  241. the information reflects the current state of the runtime
  242. modules.
  243.